import time
import sys
import config
sys.path.append('../rtlusrtos')
from rtl.tools import suffix
from cpmem.context import CTX

def main():
    fn = config.c_lib_dir+'libftcommap'+suffix()
    ctx = CTX(fn)
    ctx.open(config.c_temp_dir+'usrtos')
    def set_cb(k,p):
        ctx.callback[k] = lambda x:print(p,x)
    for i in range(len(ctx.loglevel)):
        k = ctx.loglevel[i]
        prompt = k+':'
        set_cb(k,prompt)
        
    ctx.startlog()
    while True:
        time.sleep(10)
    ctx.stoplog()

if __name__ == '__main__':
    main()
